<template>
  <div class="app-container">
   <div class="app-box">
     <div class="quick-login">
       <el-row>
         <el-col :span="24">
           <div class="quick-line">快速链接</div>
         </el-col>
       </el-row>
       <div class="btn-box clearfix">
          <div class="largeBtn" v-if="hasRule('Pages.GuaranteeSlip.Entry')" @click="toEntry">
            <div class="iconBorder color1"><i class="iconfont icon-luru03"></i></div><span>保单登记</span>
          </div>
          <div class="largeBtn" v-if="hasRule('Pages.GuaranteeSlip.Query')" @click="toQuery">
            <div class="iconBorder color2"><i class="iconfont icon-baodanchaxun2"></i></div><span>保单查询</span>
          </div>
          <div class="largeBtn" v-if="hasRule('Pages.Policy.Batch.CreateUpPolicy')" @click="toCreateUp">
            <div class="iconBorder color3"><i class="iconfont icon-chuangjian"></i></div><span>创建上游政策</span>
          </div>
          <div class="largeBtn" v-if="hasRule('Pages.Policy.Batch.CreateDownPolicy')" @click="toCreateDown">
            <div class="iconBorder color3"><i class="iconfont icon-chuangjian"></i></div><span>创建下游政策</span>
          </div>
          <div class="largeBtn" v-if="hasRule('Pages.Finance.UpSettle')" @click="toUpSettle">
              <div class="iconBorder color4"><i class="iconfont icon-jiesuanguanli"></i></div><span>上游结算</span>
            </div>
            <div class="largeBtn" v-if="hasRule('Pages.Finance.DownSettle')" @click="toDownSettle">
              <div class="iconBorder color4"><i class="iconfont icon-jiesuanguanli"></i></div><span>下游结算</span>
            </div>
            <div class="largeBtn" v-if="hasRule('Pages.Commission.Bill')" @click="toBill">
              <div class="iconBorder color5"><i class="iconfont icon-zhangdan"></i></div><span>企业账单</span>
            </div>
            <div class="largeBtn" v-if="hasRule('Pages.Commission.Send')" @click="toSend">
              <div class="iconBorder color6"><i class="iconfont icon-yongjin3"></i></div><span>佣金发放</span>
            </div>
       </div>
     </div>
     <div class="file-down">
       <el-row>
         <el-col :span="24">
           <div class="file-box">
             <span class="f1">下载出单中心</span>
             <span class="f2">出单中心下载后，能够使用出单中心连接保险公司系统进行出单。</span>
             <span class="f3" @click="toDownload">下载</span>
           </div>
         </el-col>
       </el-row>
     </div>
     <div class="get-notice">
        <el-row>
         <el-col :span="24">
           <div class="notice-row">
             <span class="row-text">消息</span>
             <!-- <span class="row-add" v-if="hasRule('Pages.Administration.Notices.Create')" @click="toadd">新增</span> -->
           </div>
         </el-col>
       </el-row>
       <div class="notice-null" v-if="noticeData.length == 0">
          <el-row>
         <el-col :span="24" class="null-text">
             <span>暂无数据</span>
         </el-col>
       </el-row>
       </div>
       <div class="notice-content" v-for="item in noticeData" v-else>
          <div class="notice-icon">
            <div class="iconBorder color1" v-if="item.state == 1"><i class="iconfont icon-gonggao"></i></div>
            <div class="iconBorder color2" v-if="item.state == 0"><i class="iconfont icon-beizhu"></i></div>
          </div>
          <div class="notice-info">
              <div class="n-top">
                <span>{{item.title}}</span>
              </div>
              <div class="n-con">{{item.content}}</div>
              <div class="n-bottom">
                <span class="b1">{{item.creationTime}}</span>
                <span class="b2">阅读人数：{{item.views}}</span>
              </div>
          </div>
          <div class="notice-toMore">
            <span @click="toDetail(item.id)">详情</span>
          </div>
       </div>
     </div>
     <div class="notice-page">
       <el-pagination @current-change="handleCurrentChange" :current-page='currentPage' background 
       :page-size="5" layout="total,prev, pager, next" :total="pagetotal"></el-pagination>
     </div>
   </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'dashboard',
  data(){
    return {
      username:'',
      userroles:[],
      currentPage:1,
      pagetotal:null,
      noticeData:[]
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'roles'
    ])
  },
  mounted() {
    let user = this.name;
    this.getNotice();
    // this.username =  user.organizationUnitsInfo.displayName
  },
  methods:{
    // 权限
    hasRule(name){
      return this.util.hasRule(name)
    },
    // 公告
    getNotice(pageindex){
      let params = {};
      if(pageindex){
        params = {
          pageSize :5,
          pageIndex : pageindex
        }
      }else{
        params = {
          pageSize :5,
          pageIndex : 1
        }
      }
      this.post(params,'services/app/common/GetHomePageNotice').then(rs => {
        if(rs.success){
          this.noticeData = rs.result.items;
          this.pagetotal = rs.result.totleCount;
        }
      })
    },
    //页码
    handleCurrentChange(val){
        console.log(`每页 ${val} 条`);
        this.currentPage = val;
        this.getNotice(val);
    },
    // 下载
    toDownload(){
      window.location.href = '/Downloads/';
    },
    // 新增
    toadd(){
      this.$router.push({
        name: 'announcenew',
        params: {
          id: '0'
        }
      })
    },
    // 详情
    toDetail(id){
      this.$router.push({
        name: 'announceD',
        query: {
          id: id
        }
      })
    },
    // 保单登记
    toEntry(){
      this.$router.push({
        name:"insentry1"
      })
    },
    // 保单查询
    toQuery(){
      this.$router.push({
        name:"policyquery"
      })
    },
    // 创建上游
    toCreateUp(){
      this.$router.push({
        name:"policyupper1"
      })
    },
    // 创建下游
    toCreateDown(){
      this.$router.push({
        name:"policydownnew"
      })
    },
    // 上游结算
    toUpSettle(){
      this.$router.push({
        name:"uppersettle1"
      })
    },
    // 下游结算
    toDownSettle(){
       this.$router.push({
        name:"financedown"
      })
    },
    // 企业账单
    toBill(){
      this.$router.push({
        name:"putout"
      })
    },
    // 佣金发放
    toSend(){
      this.$router.push({
        name:"entry1"
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.app-container{
  .app-box{
    .quick-login{
      border: 1px solid #CBCBCB;
      border-radius: 5px;
      font-size: 13px;
      .quick-line{
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #D9D9D9;
        padding:0 20px;
        font-size: 14px;
        color: #333333;
        letter-spacing: 0.62px;
        background: #FAFAFA;
        border-radius: 5px 5px 0 0;
      }
      .btn-box{
        padding:15px 7px;
          .largeBtn{
            border: 1px solid #D9D9D9;
            border-radius: 5px;
            height:88px;
            width:220px;
            line-height: 44px;
            margin:15px 13px;
            padding:20px 0 20px 20px;
            float:left;
            cursor: pointer;
            .iconBorder{
              border-radius: 5px;
              display: inline-block;
              height: 46px;
              width: 46px;
              line-height: 48px;
              text-align: center;
              margin-right: 20px;
              i{
                font-size: 26px;
              }
            }
            .color1{
              background-color:#2C9489;
              color:#fff;
            }
            .color2{
              background-color:#6B6FD2;
              color:#fff;
            }
            .color3{
              background-color:#FD9620;
              color:#fff;
            }
            .color4{
              background-color:#F56C6C;
              color:#fff;
            }
            .color5{
              background-color:#55ABDC;
              color:#fff;
            }
            .color6{
              background-color:#B352A3;
              color:#fff;
            }
            span{
              font-weight: 600;
              vertical-align: top;
              font-size: 16px;
              color: #333333;
              letter-spacing: 0.62px;
            }
        }
        .setMargin30{
          margin-bottom: 30px;
        }
      }
    }
    .file-down{
      .file-box{
        height: 62px;
        line-height: 22px;
        margin:30px 0;
        background: rgba(232,232,232,0.20);
        border: 1px solid #CBCBCB;
        border-radius: 5px;
        padding:20px;
        .f1{
          font-size: 16px;
          font-weight: 600;
          color: #333333;
          margin-right: 10px;
        }
        .f2{
          font-size: 14px;
          color: #333333;
          letter-spacing: 0.67px;
        }
        .f3{
          font-size: 14px;
          color: #027DCA;
          letter-spacing: 0.62px;
          float:right;
          cursor: pointer;
        }
      }
    }
    .get-notice{
      border: 1px solid #CBCBCB;
      border-radius: 5px;
      font-size: 13px;
      .notice-row{
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #D9D9D9;
        padding:0 20px;
        background: #FAFAFA;
        border-radius: 5px 5px 0 0;
        .row-text{
          font-size: 14px;
          color: #333333;
          letter-spacing: 0.62px;
        }
        .row-add{
          font-size: 14px;
          color: #027DCA;
          letter-spacing: 0.62px;
          float: right;
          cursor: pointer;
        }
      }
      .notice-null{
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #D9D9D9;
        padding:0 20px;
        // background: #FAFAFA;
        border-radius: 5px 5px 0 0;
        .null-text{
          font-size: 14px;
          color: #333333;
          letter-spacing: 0.62px;
          text-align: center;
        }
      }
      .notice-content{
        padding:21px 20px;
        border-bottom: 1px solid #D9D9D9;
        position: relative;
        height: 100%;
        .notice-icon{
          position: absolute;
          top:50%;
          margin-top:-22px;
            .iconBorder{
              border-radius: 50%;
              display: inline-block;
              height:45px;
              width:45px;
              line-height: 48px;
              text-align: center;
              margin-right: 21px;
              i{
                font-size: 24px;
              }
            }
            .color1{
              background-color: #F56C6C;
              color:#fff;
            }
            .color2{
              background-color: #FD9620;
              color:#fff;
            }
        }
        .notice-info{
          margin:0 50px 0 66px;
          .n-top{
            margin-bottom: 12px;
            span{
              font-size: 14px;
              color: #333333;
              letter-spacing: 0.62px;
              font-weight: 600;
            }
          }
          .n-con{
            font-size: 13px;
            color: #333333;
            letter-spacing: 0.58px;
            line-height: 25px;
            margin-bottom: 10px;
          }
          .n-bottom{
            .b1{
              font-size: 13px;
              color: #999999;
              letter-spacing: 0.58px;
              margin-right: 20px;
            }
            .b2{
              font-size: 13px;
              color: #999999;
              letter-spacing: 0.58px;
            }
          }
        }
        .notice-toMore{
          position: absolute;
          right:20px;
          top:21px;
          span{
            font-size: 13px;
            color: #027DCA;
            letter-spacing: 0.58px;
            cursor: pointer;
          }
        }
      }
      .notice-content:last-child{
        border-bottom: 0;
      }
    }
    .notice-page{
        margin:30px 0 0 0;
				text-align:right;
      }
  }
}
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
